﻿using System;
using System.Linq;
using XpressNews.SvcRef.NewsMgmt;

namespace XpressNews
{
    public partial class Article : System.Web.UI.Page
    {
        private ServiceNewsManagementClient cNews = null;
        protected News news = null;

        public News News
        {
            get
            {
                return this.news;
            }
            set
            {
                this.news = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                loadData();
            }
        }

        private void loadData()
        {
            String newsId = Request.QueryString["newsId"];
            if (String.IsNullOrEmpty(newsId))
            {
                newsId = "1";
            }

            cNews = new ServiceNewsManagementClient("newsWsHttpBinding");

            news = cNews.RetrieveNewsByID(int.Parse(newsId));

            cNews.Close();
        }
    }
}